package com.chris.design.pattern.samples.prototype;

public class ConcretePrototype2 implements AbstractPrototype {

    public ConcretePrototype2() {
    }

    public ConcretePrototype2(String name) {
        this.name = name;
    }

    private String name;


    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 克隆自身的方法（有深浅copy一说）, 这里只是简单的浅copy。 java.util.Date实现了深copy
     *
     * @return Object 一个从自身克隆出来的对象
     */
    @Override
    public Object clone() {
        AbstractPrototype abstractPrototype = new ConcretePrototype2(ConcretePrototype2.class.getSimpleName());
        return abstractPrototype;
    }
}
